home *** CD-ROM | disk | FTP | other *** search
/ Aminet 41 / Aminet 41 (2001)(Schatztruhe)[!][Feb 2001].iso / Aminet / comm / tcp / jl_update.lha / Jl_update.rexx < prev   
OS/2 REXX Batch file  |  2000-11-14  |  3KB  |  167 lines

  1. /* Just linux Dyn DNS updater v2 v1.4
  2. **
  3. **
  4. **    Requriments
  5. **
  6. **    rxsocket installede
  7. **
  8. **
  9. **    version    1.1
  10. **        addet the ability to update the env:TIADCC , requested by Xpoint
  11. **        added the ability to send a offline requeste to justlinux.com, requested by Xpoint
  12. **
  13. **    version    1.2
  14. **        changede the script so that It will let justlinux.com find your IP itself 
  15. **        and then we resolve your host name to get the ip for the TIADCC funktion.
  16. **
  17. **    version    1.3
  18. **        changede the script so that It will let justlinux.com find your IP itself 
  19. **        and then extract our IP from the returned package from the server for use
  20. **        in TIADCC. Now it`s working ;)
  21. **
  22. **    version 1.4 
  23. **        bug fixed
  24. **
  25. **    (C) 2000 Jacob Dahl Pind aka Rachael/Copy`n`Paste Tech.
  26. **
  27. **
  28. **
  29. **
  30. */
  31.  
  32.  
  33. /* config space */
  34.  
  35. user="rachael"
  36. password="dianoga"
  37.  
  38. /* host */
  39. host="rachael.penguinpowered.com"
  40.  
  41. /*
  42. **
  43. **    overrideip = 1 for overriding the automatical fetchede ip
  44. **    replace with 0 for using the fetchede ip 
  45. **
  46. **    might be usefull if your machine is on a lan
  47. **
  48. **    settia = 1 for automatical set ENV:TIADCC 
  49. **    replace with 0 to disable
  50. **
  51. **    remember to change tia_sport and tia_eport
  52. **    
  53. **
  54. */
  55.  
  56. overrideip="0"
  57. settia="1"
  58. ip="200.000.000.000"
  59. tia_sport="1024"
  60. tia_eport="1025"
  61.  
  62. /* don`t mess with the code below */
  63.  
  64. defaultserver = "www.justlinux.com"
  65. urlprefix = "/bin/controlpanel/dyndns/jlc.pl?direct=1"
  66.  
  67. Parse arg offline
  68.  
  69. call addlib("rxsocket.library",0,-30,0)
  70.  
  71. /* check for offline argument and set the IP to something bogus */
  72.  
  73. if (datatype(offline,ALPHANUMERIC)) THEN DO
  74.     ip=127.0.0.1
  75.     overrideip="1"
  76.     call send_post
  77. end
  78.  
  79. if ~(datatype(offline,ALPHANUMERIC)) THEN DO
  80.     call send_post
  81.     say "setting TIADCC"
  82.     call set_tiadcc
  83. end
  84.  
  85. exit
  86.  
  87. send_post:
  88.  
  89. if ~Open("STDERR","CONSOLE:","W") then SDTERR="STDOUT"
  90.  
  91. sin.addraddr=resolve(defaultserver)
  92. if sin.addraddr=-1 then call err "host <"host"> not found",1
  93. sin.addrport=80
  94.  
  95. sock=socket("INET","STREAM")
  96. if sock=-1 then call err "can't create socket"
  97. if connect(sock,"SIN")<0 then call err "can't connect"
  98.  
  99. fin="D0A"x
  100.  
  101. /* let the justlinux.com server find out access point ip */
  102. if ~(overrideip) then do 
  103.     ip='auto'
  104. end
  105.  
  106. request="GET" space(urlprefix'&username='user'&password='password'&host='host'&ip='ip) "HTTP/1.0"fin
  107. request=request||fin
  108.  
  109. say "sending request..."
  110. if send(sock,request)<0 then call err "error sending"
  111.  
  112. say "receiving results..."
  113. if recvline(sock,"BUF",256)<0 then call err "error receiving"
  114. if buf="" then call err "empty answer",1
  115. parse var buf http code
  116. if word(code,1)~=200 then call err "error from server" code,1
  117.  
  118. say "receiving head..."
  119. do while buf~="D0A"x
  120.     if recvline(sock,"BUF",256)<0 then call err "error receiving"
  121. end
  122.  
  123. say "receiving file..."
  124. res=recv(sock,"BUF",256)
  125.  
  126. /* extracter our Ip from the return package from the server */
  127.  
  128. ip=subword(buf,4,1)
  129. ip=SUBSTR(ip,1,(Length(ip)-1) ) 
  130.  
  131. do while res>0
  132.     call writech("STDOUT",buf)
  133.     res=recv(sock,"BUF",256)
  134.  
  135. end
  136. if res<0 then call err "error receiving"
  137.  
  138. say "done."
  139.  
  140. return
  141.  
  142.  
  143. /* Update TIADCC if our Mistress said so */
  144. set_tiadcc:
  145. if (settia) then do
  146.     open(tia,'ENV:TIADCC','W')
  147.         tias=ip' '||tia_sport' '||tia_eport
  148.         writeln(tia,tias)
  149.     close(tia)
  150. return
  151.  
  152. /* error handling procedure */
  153. err: Procedure Expose socket
  154. parse arg msg
  155.   If IsLibOn('SOCKET') Then If errno() == 4 Then msg = 'timeout'
  156.   Say 'jldyndns :' msg
  157. Exit
  158.  
  159.  
  160.  
  161.  
  162.  
  163.  
  164.  
  165.  
  166.  
  167.